from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()

class Bill(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, nullable=False)
    type = db.Column(db.String(20), nullable=False)  # 收支类型
    amount = db.Column(db.Float, nullable=False)
    category = db.Column(db.String(50), nullable=False)
    subcategory = db.Column(db.String(50))  # 二级分类
    account = db.Column(db.String(50))  # 账户
    ledger = db.Column(db.String(50))  # 账本
    remark = db.Column(db.String(200))  # 备注

    def __repr__(self):
        return f'<Bill {self.date} {self.type} {self.amount}>'